package pub.services.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import pub.dao.impl.CommonDaoImpl;
import pub.model.Users;
import pub.services.FaceBS;
import pub.util.ListUtil;

import com.dto.UsersDto;

@Service
public class FaceBSImpl implements FaceBS {
	@Resource(name="commonDaoImpl")
	private CommonDaoImpl dao;
	public UsersDto checkUser(Users user) throws Exception {
		//List list=dao.find("select count(*) from Users u where u.userCode=? and u.userPwd=?",new String[]{user.getUserCode(),user.getUserPwd()});
		//List<UsersDto> list=dao.findByExample(userLogin);
		//List<UsersDto> list=dao.find("from Users u where u.userDetail='admin' and u.userPwd='031'");
		StringBuffer sb=new StringBuffer();
		sb.append("select user_Id userId,user_Code userCode,user_Detail userDetail,user_Class userClass,user_Org_Code userOrgCode,user_Sub_Area userSubArea");
		sb.append(" from Users u where u.user_Detail='"+user.getUserDetail()+"' and u.user_Pwd='"+user.getUserPwd()+"'");
		List<UsersDto> list=dao.CDQuery(sb, UsersDto.class);
		if(ListUtil.isNull(list)){
			return null;
		}else{
			System.out.println(list.get(0).getUserCode());
			return list.get(0);
		}
	}
}
